package com.ucomm.talent.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.ucomm.talent.R;

import java.util.ArrayList;


public class ImageAdapter extends BaseAdapter{
	
	private LinearLayout[] imgItems;
	public ImageAdapter(Context c,ArrayList<Object[]> buttomList,int width,int height) {
        imgItems=new LinearLayout[buttomList.size()];
        for(int i=0;i<buttomList.size();i++)
        {
        	Object[] objs = buttomList.get(i);
        		int picId = (Integer) objs[0];
        		int text = (Integer) objs[1];
        	imgItems[i] = (LinearLayout) LayoutInflater.from(c).inflate(R.layout.bar_view, null);
        	imgItems[i].setLayoutParams(new GridView.LayoutParams(width, height));
        	if(i==0){
        		imgItems[i].setBackgroundResource(R.drawable.buttom_press);
        	}else{
        		imgItems[i].setBackgroundResource(R.drawable.buttom_press_leftline);
        	}
        	ImageView image = (ImageView) imgItems[i].findViewById(R.id.image);
        	TextView textView = (TextView) imgItems[i].findViewById(R.id.text);
        	textView.setText(text);
        	image.setImageResource(picId);
        }
    } 

    
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return imgItems.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LinearLayout imageView; 
        if (convertView == null) { 
        	imageView = imgItems[position];
        } else { 
            imageView = (LinearLayout) convertView; 
        } 
        return imageView;
	}

}
